import Vue from 'vue'
import App from './App.vue'

// 1.0 Vue的原型属性上注册好axios,将来在任何.vue文件中都可以使用this.$http去访问
import axios from 'axios'
Vue.prototype.$http = axios

// 2.0 vant组件配置好
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)

// 3.0 配置路由规则
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 3.1 注册路由规则
import Home from './components/Home.vue'
import Image from './components/Image.vue'
import News from './components/News.vue'
import Shop from './components/Shop.vue'
import NewsInfo from './components/NewsInfo.vue'
import ImageInfo from './components/ImageInfo.vue'


let router = new VueRouter({
  routes:[
    {path:'/Home',component:Home},
    {path:'/Image',component:Image},
    {path:'/News',component:News},
    {path:'/Shop',component:Shop},
    {name:'newsinfo', path:'/NewsInfo/:id' ,component:NewsInfo},
    {name:'imageinfo', path:'/ImageInfo/:imgid' ,component:ImageInfo},
  ]
})

// 注册一个全局过滤器
Vue.filter('fmt',function(value){
    // 格式化日期以后再返回
    let date = new Date(value);
    let year = date.getFullYear();
    let mouth = date.getMonth() + 1;
    let day = date.getDate();

    return `${year}-${mouth}-${day}`;
})

import VuePreview from 'vue-preview'
Vue.use(VuePreview)

Vue.config.productionTip = false

new Vue({
  render: h => h(App),
  router
}).$mount('#app')
